首页

我所使用的一些 js 选择器

记录一些稍微有点复杂的,以便于之后拓展。

知乎-订阅消息私信以及关注用户的创作活动(不包含点赞

js
/** 消息 私信 */ const userInfo = document.querySelectorAll(".AppHeader-userInfo>div:nth-child(1),.AppHeader-userInfo>div:nth-child(2)"); /** 除了点赞以外的动态 */ const feed = [...document.querySelectorAll(".Card .Feed")].filter( (el) => !el.textContent.includes("赞同了"), ); /** 结果 */ [...userInfo, ...feed.map((el) => [...el.querySelectorAll(".UserLink,h2,.RichContent-inner")]).flat()];

twitter 过滤

js
/** 移除时间 */ document.querySelectorAll('time').forEach(el=>el.remove()); /** 移除评论条 */ [...document.querySelectorAll('article>div>div>div:nth-child(2)>div:nth-child(2)>div:nth-child(3)')].forEach(el=>el.remove()); /** 移除更多icon */ [...document.querySelectorAll('article>div>div>div:nth-child(2)>div:nth-child(2)>div:nth-child(1)>div>div:nth-child(2)')].forEach(el=>el.remove()); [...document.querySelectorAll('article')].filter(el=>el.textContent.includes(""))